﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections;
using System.Collections.Generic;
using BLL.Wrapper;
using DAL.DateSet;
using DAL;

public partial class Wall : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            return;
        }

        //---------------
        // 商品层级
        //---------------

        string SupremeType = Request.Params["id"].ToString();
        string SelectedType = Request.Params["type"].ToString();
        TypeWrapper wrapper = new TypeWrapper();
        List<string> TypeList = wrapper.getSubNamebytypeName("后台管理");
        DDList1layer.Items.AddRange(DDListShow(TypeList));
        DDList1layer.SelectedIndex = DDList1layer.Items.IndexOf(DDList1layer.Items.FindByText(SupremeType));
        List<string> SubTypeList = wrapper.getSubNamebytypeName(SupremeType);
        DDList2layer.Items.AddRange(DDListShow(SubTypeList));
        DDList2layer.SelectedIndex = DDList2layer.Items.IndexOf(DDList2layer.Items.FindByText(SelectedType));
        List<string> BotTypeList;
        if (wrapper.getLevelByName(SelectedType) == 3)
        {
            DDList2layer.SelectedItem.Text = SelectedType;
            BotTypeList = wrapper.getSubNamebytypeName(SelectedType);
            if (SelectedType.Equals("乳胶漆") || SelectedType.Equals("墙纸/墙布"))
            {
                DDList3layer.Visible = false;
            }
            else
            { 
                DDList3layer.Items.AddRange(DDListShow(BotTypeList));
                SelectedType = DDList3layer.SelectedItem.Text;
            }
            
        }
        else
        {
            string parentType = wrapper.getParentName(SelectedType);
            DDList2layer.SelectedIndex = DDList2layer.Items.IndexOf(DDList2layer.Items.FindByText(parentType));
            BotTypeList = wrapper.getSubNamebytypeName(parentType);
            DDList3layer.Items.AddRange(DDListShow(BotTypeList));
            DDList3layer.SelectedIndex = DDList3layer.Items.IndexOf(DDList3layer.Items.FindByText(SelectedType));
        }
        TypeName.Text = SelectedType;    // 类别标签显示

        List<string> ProvinceList = wrapper.getSubNamebytypeName("中国");
        DDListProvince.Items.AddRange(DDListShow(ProvinceList));
        DDListProvince.SelectedIndex = DDListProvince.Items.IndexOf(DDListProvince.Items.FindByText("浙江"));
        List<string> CityList = wrapper.getSubNamebytypeName("浙江");
        DDListCity.Items.AddRange(DDListShow(CityList));

        ListItem[] country = new ListItem[6];
        country[0] = new ListItem("不选");
        country[1] = new ListItem("亚洲");
        country[2] = new ListItem("北美");
        country[3] = new ListItem("东欧");
        country[4] = new ListItem("北非");
        country[5] = new ListItem("澳洲");
        DDListCountry.Items.AddRange(country);

        //---------------
        // 商品基本信息
        //---------------

        ClassAppendWrapper caWrapper = new ClassAppendWrapper();
        string labelItem = LblMaterial.Text.Substring(0, LblMaterial.Text.LastIndexOf("："));
        DDListMaterial.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));

        //labelItem = LblFootLine.Text.Substring(0, LblFootLine.Text.LastIndexOf("："));
        //DDListFootLine.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));
        labelItem = LblStyle.Text.Substring(0, LblStyle.Text.LastIndexOf("："));
        DDListStyle.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));
        DDListFootLine.Items.Add(new ListItem("有"));
        DDListFootLine.Items.Add(new ListItem("无"));

        //labelItem = LblBrand.Text.Substring(0, LblBrand.Text.LastIndexOf("："));


        BrandWrapper bWrapper = new BrandWrapper();
        DDListBrand.Items.AddRange(DDListShow(bWrapper.getBrandName()));    //添加品牌

        switch (SelectedType)
        {
            case"文化石":
                LblFootLine.Text = "是否可以定制加工：";
                break;
            case"通体砖":
                LblMaterial.Text = "通体砖类型：";
                Lblattribute1.Text = "光泽：";
                break;
            case "玻化砖":
                LblFootLine.Text = "是否可以定制加工：";
                break;
            case "釉面砖":
                LblMaterial.Text = "纹理效果：";
                LblFootLine.Text = "是否可以定制加工：";
                break;
            case "墙纸/墙布":
                LblMaterial.Text = "面层材料：";
                Lblattribute1.Text = "面层工艺：";
                LblInside.Text = "有无图案：";
                DDListInside.Items.Add(new ListItem("有"));
                DDListInside.Items.Add(new ListItem("无"));
                break;
            case "木饰面板":
                LblMaterial.Text = "材质：";
                Lblattribute1.Text = "厚度：";
                LblInside.Text = "饰面树种：";
                LblFootLine.Text = "环保等级：";
                break;
            case"三聚氰胺板":
                LblMaterial.Text = "材质：";
                Lblattribute1.Text = "厚度：";
                LblFootLine.Visible = false;
                DDListFootLine.Visible = false;
                break;

        }
        labelItem = Lblattribute1.Text.Substring(0, Lblattribute1.Text.LastIndexOf("："));
        DDListAttribute1.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));
        if(SelectedType!="墙纸/墙布")
        {
            labelItem = LblInside.Text.Substring(0, LblInside.Text.LastIndexOf("："));
            DDListInside.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));
        }
        //labelItem = LblBottom.Text.Substring(0, LblBottom.Text.LastIndexOf("："));
        //DDListBottom.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));
        //labelItem = LblGrade.Text.Substring(0, LblGrade.Text.LastIndexOf("："));
        //DDListGrade.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));

        labelItem = LblMaterial1.Text.Substring(0, LblMaterial1.Text.LastIndexOf("："));
        DDListMaterial1.Items.AddRange(DDListShow(caWrapper.getListByNodeAndItem(SelectedType, labelItem)));
        //Response.Write(id);
        //Response.Write(type);

        //---------------
        // 商品价格信息
        //---------------

        


        //---------------
        // 商品价格信息
        //---------------

        ListItem[] service = new ListItem[4];
        service[0] = new ListItem("同城卖家入户安装");
        service[1] = new ListItem("同城卖家送货到户");
        service[2] = new ListItem("同城卖家上门提货");
        service[3] = new ListItem("同城卖家物流送货");
        DDListService.Items.AddRange(service);
    }

    public ListItem[] DDListShow(List<string> TypeList)
    {
        ListItem[] TypeArr = new ListItem[TypeList.Count];
        int i = 0;
        foreach (string item in TypeList)
        {
            ListItem type = new ListItem(item);
            TypeArr[i] = type;
            i++;
        }
        return TypeArr;
    }




    public void UploadImage(FileUpload f, Image i)
    {
        if (f.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = f.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    f.SaveAs(abPath);  //服务器保存路径
                    i.ImageUrl = rePath;
                    //TBoxFile1.Text = rePath;      //显示相对路径
                }
                else
                {
                    Response.Write("<script>alert('请上传格式为jpg,gif,bmp,png的文件!')</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('文件上传出错!')</script>");
            }

        }
        else
        {
            Response.Write("<script>alert('请选择要上传的文件!')</script>");

        }
    }

    protected void BtnAdd_Click(object sender, EventArgs e)
    {
        if (nowColor.Text.Equals("") || TBoxlength.Text.Equals("") || TBoxWidth.Text.Equals("")
           || TBoxHeight.Text.Equals("") || TBoxColorName.Text.Equals("") || TBoxUnit.Text.Equals("")
           || TBoxCount.Text.Equals("") || TBoxPrice.Text.Equals("") || TBoxInstallfee.Text.Equals("")
           || TBoxExtra.Text.Equals(""))
        {
            Response.Write("<script>alert('please fill out the forms!')</script>");
        }
        else
        {
            ArrayList arrList = new ArrayList();
            // int RowCount=1;
            if (ViewState["myList"] != null)
            {
                arrList = (ArrayList)ViewState["myList"];
            }

            string[] str = nowColor.Text.ToString().Split(',');
            string[] temp1 = str[0].Split('(');
            string[] temp2 = str[2].Split(')');
            //int red = Convert.ToInt32(temp1[1]);
            //int green = Convert.ToInt32(str[1]);
            //int blue = Convert.ToInt32(temp2[0]);
            string ImgUrl = "Image\\" + FileUpload8.FileName;
            string size = TBoxlength.Text + "*" + TBoxWidth.Text + "*" + TBoxHeight.Text;
            arrList.Add(temp1[1] + "," + str[1] + "," + temp2[0] + "," + size + "," + TBoxColorName.Text + "," + TBoxUnit.Text + ","
                        + TBoxPrice.Text + "," + TBoxCount.Text + "," + TBoxInstallfee.Text + "," + ImgUrl);
            ViewState["myList"] = arrList;
            for (int j = 0; j < arrList.Count; j++)
            {
                string[] RecordList = arrList[j].ToString().Split(',');
                Table1.Rows.Add(Row(Convert.ToInt32(RecordList[0]), Convert.ToInt32(RecordList[1]), Convert.ToInt32(RecordList[2]),
                                RecordList[3], RecordList[4], RecordList[5], RecordList[6], RecordList[7], RecordList[8], RecordList[9]));

            }
            //ViewState["package"] = PkgList;
        }
    }

    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (TBoxName.Text == "" || TBoxDescription.Text == "" || TboxScale.Text == ""
          || TBoxPackage.Text == "" || TBoxPeriod.Text == "" || TBoxWeight.Text == ""
          || TBoxFile1.Text == "" || TBoxFile2.Text == "" || TBoxFile3.Text == ""
          || TBoxFile4.Text == "" || TBoxFile5.Text == "" || TBoxFile6.Text == "")
        {
            Response.Write("<script>alert('please fill out all the forms!')</script>");
        }
        else
        {
            //插入goods表 
            GoodsWrapper goodsWrapper = new GoodsWrapper();
            Goods.GoodsDataTable goodsTable = new Goods.GoodsDataTable();
            Goods.GoodsRow row = goodsTable.NewGoodsRow();
            TypeWrapper tWrapper = new TypeWrapper();
            row.typeID = tWrapper.getIDByName(TypeName.Text);
            BrandWrapper brandWrapper = new BrandWrapper();
            row.brandID = brandWrapper.getIDByName(DDListBrand.SelectedItem.Text);
            row.goodsName = TBoxName.Text;
            row.goodsType = TboxScale.Text;
            row.goodsLocation = DDListProvince.SelectedItem.Text + DDListCity.SelectedItem.Text;
            row.packageCount = Convert.ToInt32(TBoxPackage.Text);
            row.goodsPackage = TBoxWeight.Text;
            row.goodsMaterial = DDListMaterial.SelectedItem.Text;
            row.goodsStyle = DDListStyle.SelectedItem.Text;
            if (RadioButton2.Checked)
                row.goodsBill = 0;            //发票，有为0,无为1
            else
                row.goodsBill = 1;
            row.goodsGuaranteePeriod = Convert.ToDouble(TBoxPeriod.Text);
            row.goodsCityService = Convert.ToInt16(DDListService.SelectedIndex);
            row.goodsUnit = "套";
            // row.goodsInstallCost = 0;
            row.goodsCreator = "Michael_Lin";
            row.goodsCreateDate = DateTime.Now;
            goodsWrapper.addARecord(row);

            //插入picture 表
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();

            PictureWrapper picWrapper = new PictureWrapper();
            Picture.PictureDataTable picTable = new Picture.PictureDataTable();
            Picture.PictureRow picRow = picTable.NewPictureRow();
            //picWrapper.addARecord(new Picture.PictureRow());
            picRow.pictureType = 0;
            picRow.pictureSrc = TBoxFile1.Text;
            picRow.picEditor = "Michael_Lin";
            picRow.picEditDate = DateTime.Now;
            picRow.picCreator = "Michael_Lin";
            picRow.picCreatDate = DateTime.Now;
            picRow.goodsID = helper.getIdent("Goods");
            picWrapper.addARecord(picRow);

            picRow.pictureType = 1;
            picRow.pictureSrc = TBoxFile2.Text;
            picWrapper.addARecord(picRow);

            picRow.pictureType = 2;
            picRow.pictureSrc = TBoxFile3.Text;
            picWrapper.addARecord(picRow);
            picRow.pictureSrc = TBoxFile4.Text;
            picWrapper.addARecord(picRow);
            picRow.pictureSrc = TBoxFile5.Text;
            picWrapper.addARecord(picRow);
            picRow.pictureSrc = TBoxFile6.Text;
            picWrapper.addARecord(picRow);

            picRow.pictureType = 3;
            picRow.pictureSrc = TBoxFile7.Text;
            picWrapper.addARecord(picRow);


            //插入model表和GoodsRelated表和Color表
            ModelWrapper modleWrapper = new ModelWrapper();
            Model.ModelDataTable modelTable = new Model.ModelDataTable();
            GoodsRelatedWrapper GRwrapper = new GoodsRelatedWrapper();
            GoodsRelated.GoodsRelatedDataTable GRtable = new GoodsRelated.GoodsRelatedDataTable();
            ColorWrapper colorWrapper = new ColorWrapper();
            Color.ColorDataTable colorTable = new Color.ColorDataTable();
            ArrayList arrList = null;
            if (ViewState["myList"] != null)
            {
                arrList = (ArrayList)ViewState["myList"];
                for (int i = 0; i < arrList.Count; i++)
                {
                    string[] RecordList = arrList[i].ToString().Split(',');
                    string[] size = RecordList[3].ToString().Split('*');
                    Model.ModelRow modelRow = modelTable.NewModelRow();
                    modelRow.goodsID = helper.getIdent("Goods");
                    modelRow.isDefault = 0;
                    modelRow.length = Convert.ToDouble(size[0]);
                    modelRow.width = Convert.ToDouble(size[1]);
                    modelRow.height = Convert.ToDouble(size[2]);
                    modelRow.modelSrc = RecordList[9];
                    modelRow.packageSize = TBoxPackage.Text;
                    modelRow.packageWight = Convert.ToDouble(TBoxWeight.Text);
                    modelRow.modelCreator = "Michael_Lin";
                    modelRow.modelCreateDate = DateTime.Now;
                    modleWrapper.addARecord(modelRow);
                    Color.ColorRow colorRow = colorTable.NewColorRow();
                    colorRow.goodsID = helper.getIdent("Goods");
                    colorRow.colorName = RecordList[4];
                    colorRow.colorNum = RecordList[0] + "," + RecordList[1] + "," + RecordList[2];
                    colorRow.colorCreator = "Michael_Lin";
                    colorRow.colorCreateDate = DateTime.Now;
                    colorWrapper.addARecord(colorRow);
                    GoodsRelated.GoodsRelatedRow GRrow = GRtable.NewGoodsRelatedRow();
                    GRrow.modelID = helper.getIdent("Model");
                    GRrow.colorID = helper.getIdent("Color");
                    GRrow.goodsPrice = Convert.ToDouble(RecordList[6]);
                    GRrow.goodsPriceCreator = "Michael_Lin";
                    GRrow.goodsCount = Convert.ToInt32(RecordList[7]);
                    GRrow.mapPicSrc = RecordList[9];
                    GRrow.goodsPriceDate = DateTime.Now;
                    GRrow.goodsInstallFee = Convert.ToDouble(RecordList[8]);
                    GRrow.priceUnit = RecordList[5];
                    GRrow.auxiliaryFee = 0;
                    GRwrapper.addARecord(GRrow);
                }

            }


            //插入append表
            GoodsAppendWrapper GAWrapper = new GoodsAppendWrapper();
            GoodsAppend.GoodsAppendDataTable GATable = new GoodsAppend.GoodsAppendDataTable();
            GoodsAppend.GoodsAppendRow GARow = GATable.NewGoodsAppendRow();
            GoodsAppend.GoodsAppendRow GARow1 = GATable.NewGoodsAppendRow();
            GoodsAppend.GoodsAppendRow GARow2 = GATable.NewGoodsAppendRow();
            if (TypeName.Text == "乳胶漆")
            {
                GARow.appendName = "涂层";
                GARow.appendType = "String";
                GARow.appendValue = DDListAttribute1.SelectedItem.Text;
                GARow.appendCreator = "Michael_Lin";
                GARow.appendCreateDate = DateTime.Now;
                GARow.goodsID = helper.getIdent("Goods");
                GAWrapper.addARecord(GARow);

               
                GARow2.appendName = "特种功能";
                GARow2.appendType = "String";
                GARow2.appendValue = DDListInside.SelectedItem.Text;
                GARow2.appendCreator = "Michael_Lin";
                GARow2.appendCreateDate = DateTime.Now;
                GARow2.goodsID = helper.getIdent("Goods");
                GAWrapper.addARecord(GARow2);
                
            }
            else if (TypeName.Text == "通体砖")
            {
                GARow.appendName = "光泽";
                GARow.appendType = "String";
                GARow.appendValue = DDListAttribute1.SelectedItem.Text;
                GARow.appendCreator = "Michael_Lin";
                GARow.appendCreateDate = DateTime.Now;
                GARow.goodsID = helper.getIdent("Goods");
                GAWrapper.addARecord(GARow);
            }
            else if (TypeName.Text == "墙纸/墙布")
            {
                GARow.appendName = "面层工艺";
                GARow.appendType = "String";
                GARow.appendValue = DDListAttribute1.SelectedItem.Text;
                GARow.appendCreator = "Michael_Lin";
                GARow.appendCreateDate = DateTime.Now;
                GARow.goodsID = helper.getIdent("Goods");
                GAWrapper.addARecord(GARow);

                GARow2.appendName = "有无图案";
                GARow2.appendType = "String";
                GARow2.appendValue = DDListInside.SelectedItem.Text;
                GARow2.appendCreator = "Michael_Lin";
                GARow2.appendCreateDate = DateTime.Now;
                GARow2.goodsID = helper.getIdent("Goods");
                GAWrapper.addARecord(GARow2);
            }
            else if (TypeName.Text == "三聚氰胺板")
            {
                GARow.appendName = "厚度";
                GARow.appendType = "String";
                GARow.appendValue = DDListAttribute1.SelectedItem.Text;
                GARow.appendCreator = "Michael_Lin";
                GARow.appendCreateDate = DateTime.Now;
                GARow.goodsID = helper.getIdent("Goods");
                GAWrapper.addARecord(GARow);
            }

            
           
            GARow1.appendName = "是否有同色踢脚线";
            GARow1.appendType = "String";
            GARow1.appendValue = DDListFootLine.SelectedItem.Text;
            GARow1.appendCreator = "Michael_Lin";
            GARow1.appendCreateDate = DateTime.Now;
            GARow1.goodsID = helper.getIdent("Goods");
            GAWrapper.addARecord(GARow1);




            Response.Redirect("Result.aspx");
        }

    }

    private TableRow Row(int red, int green, int blue, string size, string colorName, string unit, string price, string stock, string fee, string ImgUrl)
    {
        TableRow tr = new TableRow();
        //HtmlTableCellCollection tcc = new HtmlTableCellCollection();
        TableCell tc1 = new TableCell();
        TableCell tc2 = new TableCell();
        TableCell tc3 = new TableCell();
        TableCell tc4 = new TableCell();
        TableCell tc5 = new TableCell();
        TableCell tc6 = new TableCell();
        TableCell tc7 = new TableCell();
        TableCell tc8 = new TableCell();

        TextBox colorImg = new TextBox();
        //string ImgName = "blue.jpg";
        //string abPath = Server.MapPath("Image") + "\\" + ImgName;
        //string rePath = "Image\\" + ImgName;
        //colorImg.ImageUrl = rePath; 
        colorImg.Width = (Unit)30;
        colorImg.BackColor = System.Drawing.Color.FromArgb(red, green, blue);     //"Image\blue.jpg";
        tc1.Controls.Add(colorImg);
        tc2.Text = colorName;// ;
        tc3.Text = size;
        tc4.Text = unit;
        tc5.Text = price;// ;
        tc6.Text = stock;
        tc7.Text = fee;// ;
        tc8.Text = ImgUrl;// ;

        tr.Cells.Add(tc1);
        tr.Cells.Add(tc2);
        tr.Cells.Add(tc3);
        tr.Cells.Add(tc4);
        tr.Cells.Add(tc5);
        tr.Cells.Add(tc6);
        tr.Cells.Add(tc7);
        tr.Cells.Add(tc8);

        //package p = new package();
        //p.tr = tr;
        //p.img = img;
        //p.upload = upload;
        //p.btn = btn;
        return tr;


    }





    //protected void BtnUpload7_Click(object sender, EventArgs e)
    //{
    //    if (FileUpload1.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload1.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload1.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload1.ImageUrl = rePath;
    //                TBoxFile1.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError1.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError1.Text = "文件上传出错，请重试！";
    //            LblError1.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError1.Text = "请选择要上传的文件！";
    //        LblError1.Visible = true;
    //    }
    //    if (FileUpload2.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload2.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload2.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload2.ImageUrl = rePath;
    //                TBoxFile2.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError2.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError2.Text = "文件上传出错，请重试！";
    //            LblError2.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError2.Text = "请选择要上传的文件！";
    //        LblError2.Visible = true;
    //    }
    //    if (FileUpload3.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload3.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload3.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload3.ImageUrl = rePath;
    //                TBoxFile3.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError3.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError3.Text = "文件上传出错，请重试！";
    //            LblError3.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError3.Text = "请选择要上传的文件！";
    //        LblError3.Visible = true;
    //    }
    //    if (FileUpload4.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload4.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload4.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload4.ImageUrl = rePath;
    //                TBoxFile4.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError4.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError4.Text = "文件上传出错，请重试！";
    //            LblError4.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError4.Text = "请选择要上传的文件！";
    //        LblError4.Visible = true;
    //    }
    //    if (FileUpload5.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload5.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload5.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload5.ImageUrl = rePath;
    //                TBoxFile5.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError5.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError5.Text = "文件上传出错，请重试！";
    //            LblError5.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError5.Text = "请选择要上传的文件！";
    //        LblError5.Visible = true;
    //    }
    //    if (FileUpload6.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload6.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload6.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload6.ImageUrl = rePath;
    //                TBoxFile6.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError6.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError6.Text = "文件上传出错，请重试！";
    //            LblError6.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError6.Text = "请选择要上传的文件！";
    //        LblError6.Visible = true;
    //    }
    //    if (FileUpload7.HasFile)
    //    {
    //        try
    //        {
    //            //Response.Write(FileUpload1.FileName);

    //            string name = FileUpload7.FileName;
    //            string type = name.Substring(name.LastIndexOf(".") + 1);
    //            string abPath = Server.MapPath("Image") + "\\" + name;
    //            string rePath = "Image\\" + name;
    //            if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
    //            {
    //                FileUpload7.SaveAs(abPath);  //服务器保存路径
    //                ImgUpload7.ImageUrl = rePath;
    //                TBoxFile7.Text = rePath;      //显示相对路径
    //            }
    //            else
    //            {
    //                LblError7.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            LblError7.Text = "文件上传出错，请重试！";
    //            LblError7.Visible = true;
    //        }

    //    }
    //    else
    //    {
    //        LblError7.Text = "请选择要上传的文件！";
    //        LblError7.Visible = true;
    //    }
    //}


    protected void DDListProvince_SelectedIndexChanged(object sender, EventArgs e)
    {
        string SelectedProvince = DDListProvince.SelectedItem.Text;
        DDListCity.Items.Clear();
        TypeWrapper TWrapper = new TypeWrapper();
        List<string> cityList = TWrapper.getSubNamebytypeName(SelectedProvince);
        DDListCity.Items.AddRange(DDListShow(cityList));
    }

    protected void DDList1layer_SelectedIndexChanged(object sender, EventArgs e)
    {
        string SelectedType = DDList1layer.SelectedItem.Text;
        DDList2layer.Items.Clear();
        TypeWrapper TWrapper = new TypeWrapper();
        List<string> TypeList = TWrapper.getSubNamebytypeName(SelectedType);
        DDList2layer.Items.AddRange(DDListShow(TypeList));
    }

    protected void BtnUpload1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload1.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload1.SaveAs(abPath);  //服务器保存路径
                    ImgUpload1.ImageUrl = rePath;
                    TBoxFile1.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError1.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError1.Text = "文件上传出错，请重试！";
                LblError1.Visible = true;
            }

        }
        else
        {
            LblError1.Text = "请选择要上传的文件！";
            LblError1.Visible = true;
        }
    }
    protected void BtnUpload2_Click(object sender, EventArgs e)
    {
        if (FileUpload2.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload2.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload2.SaveAs(abPath);  //服务器保存路径
                    ImgUpload2.ImageUrl = rePath;
                    TBoxFile2.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError2.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError2.Text = "文件上传出错，请重试！";
                LblError2.Visible = true;
            }

        }
        else
        {
            LblError2.Text = "请选择要上传的文件！";
            LblError2.Visible = true;
        }
        if (FileUpload3.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload3.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload3.SaveAs(abPath);  //服务器保存路径
                    ImgUpload3.ImageUrl = rePath;
                    TBoxFile3.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError3.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError3.Text = "文件上传出错，请重试！";
                LblError3.Visible = true;
            }

        }
        else
        {
            LblError3.Text = "请选择要上传的文件！";
            LblError3.Visible = true;
        }
        if (FileUpload4.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload4.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload4.SaveAs(abPath);  //服务器保存路径
                    ImgUpload4.ImageUrl = rePath;
                    TBoxFile4.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError4.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError4.Text = "文件上传出错，请重试！";
                LblError4.Visible = true;
            }

        }
        else
        {
            LblError4.Text = "请选择要上传的文件！";
            LblError4.Visible = true;
        }
        if (FileUpload5.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload5.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload5.SaveAs(abPath);  //服务器保存路径
                    ImgUpload5.ImageUrl = rePath;
                    TBoxFile5.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError5.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError5.Text = "文件上传出错，请重试！";
                LblError5.Visible = true;
            }

        }
        else
        {
            LblError5.Text = "请选择要上传的文件！";
            LblError5.Visible = true;
        }
        if (FileUpload6.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload6.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload6.SaveAs(abPath);  //服务器保存路径
                    ImgUpload6.ImageUrl = rePath;
                    TBoxFile6.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError6.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError6.Text = "文件上传出错，请重试！";
                LblError6.Visible = true;
            }

        }
        else
        {
            LblError6.Text = "请选择要上传的文件！";
            LblError6.Visible = true;
        }
    }
    protected void BtnUpload3_Click(object sender, EventArgs e)
    {
        if (FileUpload7.HasFile)
        {
            try
            {
                //Response.Write(FileUpload1.FileName);

                string name = FileUpload7.FileName;
                string type = name.Substring(name.LastIndexOf(".") + 1);
                string abPath = Server.MapPath("Image") + "\\" + name;
                string rePath = "Image\\" + name;
                if (type == "jpg" || type == "gif" || type == "bmp" || type == "png")
                {
                    FileUpload7.SaveAs(abPath);  //服务器保存路径
                    ImgUpload7.ImageUrl = rePath;
                    TBoxFile7.Text = rePath;      //显示相对路径
                }
                else
                {
                    LblError7.Text = "请上传格式为（jpg,gif,bmp,png）的文件！";
                }
            }
            catch (Exception ex)
            {
                LblError7.Text = "文件上传出错，请重试！";
                LblError7.Visible = true;
            }

        }
        else
        {
            LblError7.Text = "请选择要上传的文件！";
            LblError7.Visible = true;
        }
    }

}
